const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "自增id",
      field: "id"
    },
    brand_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: true,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "品牌id",
      field: "brand_id"
    },
    site_type: {
      type: DataTypes.INTEGER(1),
      allowNull: false,
      defaultValue: "-1",
      primaryKey: false,
      autoIncrement: false,
      comment: "商品类型（跟随站点类型一致[0销售, 1展示, 2自提, 3虚拟销售, 4销售+自提]）",
      field: "site_type"
    },
    title: {
      type: DataTypes.CHAR(160),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "标题",
      field: "title"
    },
    title_color: {
      type: DataTypes.CHAR(7),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "标题颜色",
      field: "title_color"
    },
    simple_desc: {
      type: DataTypes.CHAR(230),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "简述",
      field: "simple_desc"
    },
    model: {
      type: DataTypes.CHAR(30),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "型号",
      field: "model"
    },
    place_origin: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "产地（地区省id）",
      field: "place_origin"
    },
    inventory: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "库存（所有规格库存总和）",
      field: "inventory"
    },
    inventory_unit: {
      type: DataTypes.CHAR(15),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "库存单位",
      field: "inventory_unit"
    },
    images: {
      type: DataTypes.CHAR(255),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "封面图片",
      field: "images"
    },
    original_price: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "原价（单值:10, 区间:10.00-20.00）一般用于展示使用",
      field: "original_price"
    },
    min_original_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "最低原价",
      field: "min_original_price"
    },
    max_original_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "最大原价",
      field: "max_original_price"
    },
    price: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "销售价格（单值:10, 区间:10.00-20.00）一般用于展示使用",
      field: "price"
    },
    min_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "最低价格",
      field: "min_price"
    },
    max_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "最高价格",
      field: "max_price"
    },
    give_integral: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "购买赠送积分比例",
      field: "give_integral"
    },
    buy_min_number: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "1",
      primaryKey: false,
      autoIncrement: false,
      comment: "最低起购数量 （默认1）",
      field: "buy_min_number"
    },
    buy_max_number: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "最大购买数量（最大数值 100000000, 小于等于0或空则不限）",
      field: "buy_max_number"
    },
    is_deduction_inventory: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "1",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否扣减库存（0否, 1是）",
      field: "is_deduction_inventory"
    },
    is_shelves: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "1",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否上架（下架后用户不可见, 0否, 1是）",
      field: "is_shelves"
    },
    content_web: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "电脑端详情内容",
      field: "content_web"
    },
    photo_count: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "相册图片数量",
      field: "photo_count"
    },
    sales_count: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "销量",
      field: "sales_count"
    },
    access_count: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "访问次数",
      field: "access_count"
    },
    video: {
      type: DataTypes.CHAR(255),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "短视频",
      field: "video"
    },
    is_exist_many_spec: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否存在多个规格（0否, 1是）",
      field: "is_exist_many_spec"
    },
    spec_base: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "规格基础数据",
      field: "spec_base"
    },
    fictitious_goods_value: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "虚拟商品展示数据",
      field: "fictitious_goods_value"
    },
    seo_title: {
      type: DataTypes.CHAR(100),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "SEO标题",
      field: "seo_title"
    },
    seo_keywords: {
      type: DataTypes.CHAR(130),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "SEO关键字",
      field: "seo_keywords"
    },
    seo_desc: {
      type: DataTypes.CHAR(230),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "SEO描述",
      field: "seo_desc"
    },
    is_delete_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否已删除（0 未删除, 大于0则是删除时间）",
      field: "is_delete_time"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    },
    upd_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "更新时间",
      field: "upd_time"
    }
  };
  const options = {
    tableName: "sxo_goods",
    comment: "",
    indexes: [{
      name: "title",
      unique: false,
      type: "BTREE",
      fields: ["title"]
    }, {
      name: "access_count",
      unique: false,
      type: "BTREE",
      fields: ["access_count"]
    }, {
      name: "photo_count",
      unique: false,
      type: "BTREE",
      fields: ["photo_count"]
    }, {
      name: "is_shelves",
      unique: false,
      type: "BTREE",
      fields: ["is_shelves"]
    }, {
      name: "brand_id",
      unique: false,
      type: "BTREE",
      fields: ["brand_id"]
    }, {
      name: "sales_count",
      unique: false,
      type: "BTREE",
      fields: ["sales_count"]
    }, {
      name: "is_delete_time",
      unique: false,
      type: "BTREE",
      fields: ["is_delete_time"]
    }]
  };
  const SxoGoodsModel = sequelize.define("sxo_goods_model", attributes, options);
  return SxoGoodsModel;
};